import request from '@/utils/request'

const baseUri = '/storage'

const storageApi = {
    //仓库 列表
    list({ page, limit, ...others }) {
        return request({
            url: `${baseUri}/list`,
            method: 'get',
            params: {
                page,
                limit,
                ...others
            }
        })
    },
    //根据id查找仓库
    findById(id) {
        return request({
            url: `${baseUri}/findById?id=`+id,
            method: 'get',
            params: { id }
        })
    },

    //查询所有仓库
    findAll() {
        return request({
            url: `${baseUri}/findAll`,
            method: 'get'
        })
    },
    //添加仓库
    add(pojo) {
        return request({
            url: `${baseUri}/add`,
            method: 'post',
            data: pojo
        })
    },

    //修改仓库
    update(id,pojo) {
        if(id===null || id===''){
          return this.add(pojo)
        }
        return request({
          url: `${baseUri}/update`,
          method: 'post',
          data: pojo // 将 maintenRecord 对象作为请求体传递
        })
      },
    // 删除仓库
    delete(id) {
        return request({
            url: baseUri + '/delete?id='+id,
            method: 'get',
            params: { id }
        })
    },
    //批量删除仓库
    batchRemove(ids) {
        return request({
            url: `${baseUri}/batchRemove`,
            method: 'post',
            data: ids
        })
    }
}
export default storageApi